﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Web;

namespace AgileMaster.Core.Configuration
{
    public class ApplicationSettings
    {
        private HttpContextBase _httpContext;

        /// <summary>
        /// The human-friendly current Roadkill product version, e.g. "1.7.0-Beta3".
        /// </summary>
        public static string ProductVersion
        {
            get
            {
                return FileVersionInfo.GetVersionInfo(typeof(ApplicationSettings).Assembly.Location).ProductVersion;
            }
        }

        /// <summary>
        /// The file version of the Roadkill product version, e.g. "1.7.0.0"
        /// </summary>
        public static string FileVersion
        {
            get
            {
                return FileVersionInfo.GetVersionInfo(typeof(ApplicationSettings).Assembly.Location).FileVersion;
            }
        }
        
        /// <summary>
        /// Gets a value indicating whether this windows authentication is being used.
        /// </summary>
        public bool UseWindowsAuthentication { get; set; }
        
        /// <summary>
        /// The fully qualified assembly and classname for the repository.
        /// </summary>
        public string RepositoryType { get; set; }

        /// <summary>
        /// True if the version number in the web.config does not match the current assembly version.
        /// </summary>
        public bool UpgradeRequired { get; internal set; }

        /// <summary>
        /// The type of logging to perform, which can be a comma seperated list of values or just a single value.
        /// </summary>
        public string LoggingTypes { get; set; }

        /// <summary>
        /// Whether to just error messages are logged, or all information (warnings, information).
        /// </summary>
        public bool LogErrorsOnly { get; set; }

        /// <summary>
        /// Indicates whether the installation has been completed previously.
        /// </summary>
        public bool Installed { get; set; }

        /// <summary>
		/// Initializes a new instance of the <see cref="ApplicationSettings"/> class.
		/// </summary>
        public ApplicationSettings()
        {
            if (HttpContext.Current != null)
                _httpContext = new HttpContextWrapper(HttpContext.Current);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ApplicationSettings"/> class.
        /// </summary>
        /// <param name="httpContext">The HTTP context.</param>
        internal ApplicationSettings(HttpContextBase httpContext)
            : this()
        {
            _httpContext = httpContext;
        }
    }
}